package com.hjm.project.ShopOrderRecord.ShopOrderRecord.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ShopOrderRecord.ShopOrderRecord.domain.ShopOrderRecord;
import com.hjm.project.ShopOrderRecord.ShopOrderRecord.service.IShopOrderRecordService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 订单状态记录Controller
 * 
 * @author ShopOrderRecord
 * @date 2020-11-30
 */
@Controller
@RequestMapping("/ShopOrderRecord/ShopOrderRecord")
public class ShopOrderRecordController extends BaseController
{
    private String prefix = "ShopOrderRecord/ShopOrderRecord";

    @Autowired
    private IShopOrderRecordService shopOrderRecordService;

    @RequiresPermissions("ShopOrderRecord:ShopOrderRecord:view")
    @GetMapping()
    public String ShopOrderRecord()
    {
        return prefix + "/ShopOrderRecord";
    }

    /**
     * 查询订单状态记录列表
     */
    @RequiresPermissions("ShopOrderRecord:ShopOrderRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ShopOrderRecord shopOrderRecord)
    {
        startPage();
        List<ShopOrderRecord> list = shopOrderRecordService.selectShopOrderRecordList(shopOrderRecord);
        return getDataTable(list);
    }

    /**
     * 导出订单状态记录列表
     */
    @RequiresPermissions("ShopOrderRecord:ShopOrderRecord:export")
    @Log(title = "订单状态记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ShopOrderRecord shopOrderRecord)
    {
        List<ShopOrderRecord> list = shopOrderRecordService.selectShopOrderRecordList(shopOrderRecord);
        ExcelUtil<ShopOrderRecord> util = new ExcelUtil<ShopOrderRecord>(ShopOrderRecord.class);
        return util.exportExcel(list, "ShopOrderRecord");
    }

    /**
     * 新增订单状态记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存订单状态记录
     */
    @RequiresPermissions("ShopOrderRecord:ShopOrderRecord:add")
    @Log(title = "订单状态记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ShopOrderRecord shopOrderRecord)
    {
        return toAjax(shopOrderRecordService.insertShopOrderRecord(shopOrderRecord));
    }

    /**
     * 修改订单状态记录
     */
    @GetMapping("/edit/{updateDate}")
    public String edit(@PathVariable("updateDate") String updateDate, ModelMap mmap)
    {
        ShopOrderRecord shopOrderRecord = shopOrderRecordService.selectShopOrderRecordById(updateDate);
        mmap.put("shopOrderRecord", shopOrderRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存订单状态记录
     */
    @RequiresPermissions("ShopOrderRecord:ShopOrderRecord:edit")
    @Log(title = "订单状态记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ShopOrderRecord shopOrderRecord)
    {
        return toAjax(shopOrderRecordService.updateShopOrderRecord(shopOrderRecord));
    }

    /**
     * 删除订单状态记录
     */
    @RequiresPermissions("ShopOrderRecord:ShopOrderRecord:remove")
    @Log(title = "订单状态记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(shopOrderRecordService.deleteShopOrderRecordByIds(ids));
    }
}
